/**
 * 存放自定义组件
 */
import { defineStore } from 'pinia';

export const useCustomComponentStore = defineStore('customComponent', {
	state: () => ({
		customComponentList: []
	}),
	getters: {
		getCustomComponentList: async (state) => {
			return state.customComponentList ? state.customComponentList : await uni.getStorage({ key: "customComponentList" })
		}
	},
	actions: {

		setCustomComponentList: (list) => {
			const _this = useCustomComponentStore()
			_this.$state.customComponentList = list
			uni.setStorage({ key: "customComponentList", data: list })
		},
		pushCustomComponentList: (component) => {
			const _this = useCustomComponentStore()
			_this.$state.customComponentList.push(component)
			uni.setStorage({ key: "customComponentList", data: _this.$state.customComponentList })
		}
	}

})